<template>
 <div style="font-size: 12px;line-height: 60px ;display: flex">
  <div style="flex: 1;">
    <span :class="collapseBtnClass" style="cursor: pointer; font-size: 18px" @click="handleCollapse"></span>

    <el-breadcrumb separator="/" style="display: inline-block;margin-left: 10px">
      <template v-if="$route.path !== '/manage'">
        <el-breadcrumb-item :to="'/manage'">首页</el-breadcrumb-item>
      </template>
      <template v-if="$route.path !== '/manage/home'">
        <el-breadcrumb-item>{{currentPathName}}</el-breadcrumb-item>
      </template>
    </el-breadcrumb>

    <!--    <div style="margin-bottom: 30px">-->
<!--    </div>-->
  </div>
   <el-dropdown style="width: 100px;cursor: pointer">
     <div style="display: inline-block">
       <img src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fsafe-img.xhscdn.com%2Fbw1%2Fb420e1ac-6042-4d62-adbd-490724e2cf3a%3FimageView2%2F2%2Fw%2F1080%2Fformat%2Fjpg&refer=http%3A%2F%2Fsafe-img.xhscdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1682670214&t=11e1a9308ee7a41519c2728ed77925bf" alt="" style="width: 30px;border-radius: 50%;position: relative;top: 10px;right: 5px">
       <span>小张</span><i class="el-icon-arrow-down" style="margin-left: 5px"></i>
     </div>
     <el-dropdown-menu slot="dropdown" style="width: 100px;text-align: center">
       <el-dropdown-item style="font-size: 14px;padding: 5px 0">个人信息</el-dropdown-item>
       <el-dropdown-item style="font-size: 14px;padding: 5px 0">
         <router-link to="/login" style="text-decoration: none">退出</router-link>
       </el-dropdown-item>
     </el-dropdown-menu>
   </el-dropdown>
  </div>
</template>

<script>
import store from "@/store/index";
export default {
  name: "Header",
  props:{
    collapseBtnClass:String,
    collapse:Function,
  },
  // computed:{
  //   currentPathName(){
  //     return this.$store.state.currentPathName;
  //   }
  // },
  computed: {
    store() {
      return this.$store || this.$root.$options.store;
    },
    currentPathName() {
      return this.store.state.currentPathName;
    }
  },
  watch:{
    //监听路由变化
    // '$route': function () {
    //   this.currentRouteName = localStorage.getItem("currentRouteName")   //取出路由名称
    // }
    currentPathName (newVal,oldVal) {
      console.log(newVal)
    }
  },
  data() {
    return {

    }
  },
  methods: {
    handleCollapse() {
      if (typeof this.collapse === 'function') {
        this.collapse(); // 调用传递过来的函数
      }
    }
  }
}
</script>

<style scoped>

</style>
